export default {
    resolvers: {
        Mutation: {
            openModal: (_, props, {cache}) => {
                const {name, title = 'No Title', args = {}, width} = props
                cache.writeData({
                    data: {
                        modal: {
                            name,
                            width,
                            open: true,
                            title,
                            onOk: args.onOk,
                            args: JSON.stringify(args),
                            __typename: 'Modal',
                        }
                    },
                })
                return null
            },
            closeModal: (_, __, {cache}) => {
                cache.writeData({data: {modal: {open: false, __typename: 'Modal'}}})
                return null
            }
        }
    },
    defaults: {
        modal: {
            __typename: 'Modal',
            name: '',
            width: null,
            open: false,
            title: 'test',
            args: '{}',
        }
    }
}
